@use '../core' as *;

.frameworkSelector {
    --height: 38px; // Match button height
    --icon-size: #{$spacing-size-6};
    --x-padding: 10px;

    display: flex;
    width: 100%;
    border-radius: var(--radius-sm);
    background-color: var(--color-bg-primary);

    border: 1px solid transparent;

    #{$selector-darkmode} & {
        --color-bg-primary: var(--color-bg-primary);
        border-color: var(--color-bg-primary);
    }
}

.option {
    --color-link: var(--color-fg-primary);
    --color-link-hover: var(--color-fg-primary);

    display: flex;
    position: relative;
    align-items: center;
    min-width: $spacing-size-12;
    padding: calc((var(--height) - var(--icon-size)) / 2) var(--x-padding);
    text-decoration: none;
    outline: none;

    &::after {
        content: '';
        position: absolute;
        height: 2px;
        bottom: -2px;
        left: 5px;
        right: 5px;
        background-color: var(--color-input-bg-checked);
        opacity: 0;
        transition: opacity $transition-default-timing;
    }

    img {
        width: var(--icon-size);
        height: var(--icon-size);
    }

    span {
        display: none;
        margin-left: 4px;
        font-size: var(--text-fs-base);
        transition: opacity $transition-default-timing;
    }

    &:hover,
    &:focus-visible {
        text-decoration: none;
    }
}

.frameworkSelector.showSelected {
    border: 2px solid var(--color-input-border);

    @media screen and (min-width: $breakpoint-docs-search-medium) {
        width: auto;
    }

    border: 1px solid transparent;

    #{$selector-darkmode} & {
        border-color: 1px solid var(--color-border-primary);
    }
}

.frameworkSelector.showSelected .option {
    width: 25%;

    span {
        opacity: 0.6666;
    }

    &:hover,
    &:focus-visible {
        &::after {
            opacity: 0.5;
        }

        span {
            opacity: 0.85;
        }
    }

    &.selected {
        span,
        &::after,
        &:hover::after,
        &:focus-visible::after {
            opacity: 1;
        }
    }

    @media screen and (min-width: $breakpoint-fw-selector-show-selected-medium) {
        width: unset;
        padding: calc((var(--height) - var(--icon-size)) / 2) 10px;

        &:first-child {
            padding-left: calc(var(--x-padding) * 2);

            &::after {
                left: calc(var(--x-padding) * 1.5);
            }
        }

        &:last-child {
            padding-right: calc(var(--x-padding) * 2);

            &::after {
                right: calc(var(--x-padding) * 1.5);
            }
        }

        span {
            display: inline;
        }
    }
}

.frameworkSelector.fullWidth {
    --height: #{$spacing-size-12};

    min-width: 220px;
    max-width: 420px;
    border-radius: var(--radius-md);

    @media screen and (min-width: 740px) {
        width: unset;
        max-width: unset;
    }

    @media screen and (min-width: $breakpoint-fw-selector-full-width-large) {
        --height: #{$spacing-size-16};
        --icon-size: #{$spacing-size-10};

        font-size: var(--text-fs-xl);
    }

    border: 1px solid transparent;

    #{$selector-darkmode} & {
        border-color: var(--color-border-primary);
    }
}

.frameworkSelector.fullWidth .option {
    width: 25%;

    &:hover::after,
    &:focus-visible::after {
        opacity: 1;
    }

    img {
        border-radius: 14%;
    }

    @media screen and (min-width: $breakpoint-fw-selector-full-width-medium) {
        width: unset;
        padding: calc((var(--height) - var(--icon-size)) / 2) var(--x-padding);

        &:first-child {
            padding-left: calc(var(--x-padding) * 2);

            &::after {
                left: calc(var(--x-padding) * 1.5);
            }
        }

        &:last-child {
            padding-right: calc(var(--x-padding) * 2);

            &::after {
                right: var(--x-padding);
            }
        }

        span {
            display: inline;
        }
    }

    @media screen and (min-width: $breakpoint-fw-selector-full-width-large) {
        &::after {
            height: 3px;
            border-radius: 1.5px;
        }

        span {
            margin-left: $spacing-size-2;
            font-size: var(--text-fs-xl);
        }
    }
}
